package cn.aitrox.ry.app.web.controller.anno;

import cn.aitrox.ry.bean.CommonPageInfo;
import cn.aitrox.ry.bean.RespResult;
import cn.aitrox.ry.common.controller.BaseController;
import cn.aitrox.ry.service.anno.dto.user.task.in.TaskAnnoInfoInDto;
import cn.aitrox.ry.service.anno.dto.user.task.in.TaskJoinableSearchInDto;
import cn.aitrox.ry.service.anno.dto.user.task.in.UserTaskJoinInDto;
import cn.aitrox.ry.service.anno.dto.user.task.in.UserTaskSearchInDto;
import cn.aitrox.ry.service.anno.dto.user.task.out.UserTaskItemDto;
import cn.aitrox.ry.service.anno.dto.user.task.series.in.UserTaskSeriesSearchInDto;
import cn.aitrox.ry.service.anno.dto.user.task.series.out.UserTaskSeriesDto;
import cn.aitrox.ry.service.anno.feign.UserTaskFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserTaskController extends BaseController {

    @Autowired
    @Lazy
    private UserTaskFeign userTaskFeign;

    @GetMapping(value = "/anno/user/doing/task/list")
    public RespResult<List<UserTaskItemDto>> userDoingTaskList() {
        List<UserTaskItemDto> userTaskItems = userTaskFeign.userDoingTaskList();
        return RespResult.ok(userTaskItems);
    }

    @PostMapping(value = "/anno/user/task/search")
    public RespResult<CommonPageInfo<UserTaskItemDto>> search(@RequestBody UserTaskSearchInDto input) {
        CommonPageInfo<UserTaskItemDto> pageInfo = userTaskFeign.search(input);
        return RespResult.ok(pageInfo);
    }

    @PostMapping(value = "/anno/task/joinable/search")
    public RespResult<CommonPageInfo<UserTaskItemDto>> joinableSearch(@RequestBody TaskJoinableSearchInDto input) {
        CommonPageInfo<UserTaskItemDto> pageInfo = userTaskFeign.joinableSearch(input);
        return RespResult.ok(pageInfo);
    }

    @PostMapping(value = "/anno/task/join")
    public RespResult userTaskJoin(@Validated @RequestBody UserTaskJoinInDto input) {
        return userTaskFeign.userTaskJoin(input);
    }

    @PostMapping(value = "/anno/user/task/series/search")
    public RespResult<CommonPageInfo<UserTaskSeriesDto>> userTaskSeriesSearch(@RequestBody UserTaskSeriesSearchInDto input) {
        CommonPageInfo<UserTaskSeriesDto> pageInfo = userTaskFeign.userTaskSeriesSearch(input);
        return RespResult.ok(pageInfo);
    }

    @PostMapping(value = "/anno/task/anno/info")
    public RespResult<UserTaskItemDto> taskAnnoInfo(@Validated @RequestBody TaskAnnoInfoInDto input) {
        return userTaskFeign.taskAnnoInfo(input);
    }

}
